import 'package:hongsheng/utils/SPClassCommonMethods.dart';
import 'package:hongsheng/utils/colors.dart';
import 'package:hongsheng/widgets/SPClassToolBar.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';


import 'SPClassExchangeItemPage.dart';

class SPClassExchangeRecordPage extends StatefulWidget {
  const SPClassExchangeRecordPage({Key ?key}) : super(key: key);

  @override
  _SPClassExchangeRecordPageState createState() => _SPClassExchangeRecordPageState();
}

class _SPClassExchangeRecordPageState extends State<SPClassExchangeRecordPage> with TickerProviderStateMixin{
  List tabBarList =['全部','待发货','已发货'];
  List<SPClassExchangeItemPage> list =[];
  TabController ?_controller;
  List statusList= ['','1','2'];

  @override
  void initState() {
    // TODO: implement initState
    super.initState();

    _controller=TabController(length: tabBarList.length,vsync: this,initialIndex: 0);

    list = tabBarList.map((e) {
      return SPClassExchangeItemPage(type: statusList[tabBarList.indexOf(e)],);
    }).toList();
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: SPClassToolBar(
        context,title: "兑换记录",),
      body: Column(
        children: <Widget>[
          Container(
            color: Colors.white,
            child: TabBar(
              labelColor: MyColors.main1,
              labelPadding: EdgeInsets.zero,
              unselectedLabelColor: Color(0xFF333333),
              indicatorColor: MyColors.main1,
              isScrollable: false,
              indicatorSize:TabBarIndicatorSize.label,
              labelStyle: TextStyle(fontSize: sp(13)),
              unselectedLabelStyle:  TextStyle(fontSize: sp(13)),
              controller: _controller,
              tabs:tabBarList.map((tab){
                return Tab(text: tab,);
              }).toList() ,
            ),
          ),
          Expanded(
            child: TabBarView(
              controller: _controller,
              children: list,
            ),
          )
        ],
      ),

    );
  }
}
